package com.example.teatea.controller;

import com.example.teatea.dao.DoFindMember;
import com.example.teatea.dao.DoFindStaff;
import com.example.teatea.project.Member;
import com.example.teatea.project.Staff;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;

import java.util.List;

public class FindStaffController {
    public TextField nameFind;
    public Button findBt;
    public TextField phoneFind;
    public Button findBt1;

    public void toFind(ActionEvent actionEvent) {
        List<Staff> subList =new DoFindStaff().findStaffByName(nameFind.getText());
        ObservableList<Staff> data = FXCollections.observableArrayList();
        for(Staff staff : subList){
            data.add(staff);
        }
        MainController mainController = (MainController) ControllerManager.controllerMap.get("main");
        mainController.staffView.setItems(data);
    }

    public void toFind1(ActionEvent actionEvent) {
        List<Staff> subList =new DoFindStaff().findStaffByPhone(phoneFind.getText());
        ObservableList<Staff> data = FXCollections.observableArrayList();
        for(Staff staff : subList){
            data.add(staff);
        }
        MainController mainController = (MainController) ControllerManager.controllerMap.get("main");
        mainController.staffView.setItems(data);
    }
}
